package edu.java.lectures.lec12.threads.synchronization.dynamic.msgbox;

public class MsgBoxTest {

    private static final int MSG_PUBLISHER_COUNT = 4;
    private static final int MSG_READERS_COUNT = 1;

    public static void main(String[] args) {
	MsgBox msgBox = new MsgBox();

	// MsgPublisher publisher1 = new MsgPublisher("p1", msgBox);
	// MsgReader msgReader1 = new MsgReader("r1", msgBox);
	// MsgReader msgReader2 = new MsgReader("r2", msgBox);

	MsgPublisher[] msgPublishers = new MsgPublisher[MSG_PUBLISHER_COUNT];
	for (int i = 0; i < msgPublishers.length; i++) {
	    msgPublishers[i] = new MsgPublisher("[P-" + (i + 1) + "]", msgBox);
	}

	MsgReader[] msgReaders = new MsgReader[MSG_READERS_COUNT];
	for (int i = 0; i < msgReaders.length; i++) {
	    msgReaders[i] = new MsgReader("[R-" + (i + 1) + "]", msgBox);
	}

	// publisher1.start();

	for (MsgPublisher msgPublisher : msgPublishers) {
	    msgPublisher.start();
	}
	for (MsgReader msgReader : msgReaders) {
	    msgReader.start();
	}
	// msgReader1.start();
	// msgReader2.start();
    }
}
